package com.superhelper.app.service;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.superhelper.app.domain.PageModel;
import com.superhelper.app.mapper.UserMapper;
import com.superhelper.common.domain.User;

@Service
public class UserService {
	protected Logger log = LoggerFactory.getLogger(this.getClass());
	@Autowired(required = true)
	private UserMapper userMapper;

	public List<User> getList(Long userId, Integer page, Integer pageSize) {
		PageModel pageModel = new PageModel();
		pageModel.setPageSize(pageSize);
		pageModel.setPageIndex(page);
		List<User> list = userMapper.getUserList(pageModel, userId);
		for (User u : list) {
			if (u.getSource() != null) {
				String source = u.getSource().replaceAll("mt", "美团")
						.replaceAll("ele", "饿了么").replaceAll("bd", "百度");
				u.setSource(source);
			}
			u.setTotalMoney(u.getEle_money().add(u.getMt_money()));
		}
		return list;
	}
}
